<style>
    .layui-form .layui-form-item .layui-inline .layui-form-label {
        width: 250px;
        font-size: 16px;
    }
    .layui-form .layui-form-item .layui-inline .layui-input-inline input {
        font-size: 13px;
        width: 270px;
        border: 0px;
    }
    .title_css {
        font-size: 20px;
        font-weight: bold;
    }
</style>
<form class="layui-form  seller-alone-form" id="userAdd" style="padding:20px;height: auto;">
    <fieldset class="layui-elem-field layui-field-title">
        <legend>
            <a href="{:url('check')}" style="color: #428bca;font-weight:bold;" >User Check</a> / Edit
        </legend>
    </fieldset>
    <br/>
    <div class="title_css">Applicant Details</div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">Email：</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" value="{$data.applicant.email}">
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">First Name：</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" value="{$data.applicant.first_name}">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">Last Name：</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" value="{$data.applicant.last_name}">
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">Registered Business Name：</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" value="{$data.applicant.company_name}">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">Company Phone Number：</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" value="{$data.applicant.company_phone}">
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">Company Belw：</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" value="{$data.applicant.company_role}">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">Promo Code：</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" value="{$data.applicant.promo_code}">
            </div>
        </div>
    </div>
    <div class="title_css">Verify your business.(1/2)</div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">Legal registered business name：</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" value="{$data.business_one.business_name}">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">DBA name-fictitious business：</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" value="{$data.business_one.fictitious_name}">
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">Ownership Type：</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" value="{$data.business_one.ownership_type}">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">Company Phone Number：</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" value="{$data.business_one.business_company_phone}">
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">State Of Incorporation：</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" value="{$data.business_one.incorporation_state}">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">Date Established：</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" value="{$data.business_one.established_date}">
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">Business structure：</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" value="{$data.business_one.business_structure}">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">Industry：</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" value="{$data.business_one.industry}">
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">Industry subcategory：</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" value="{$data.business_one.industry_subcategory}">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">Company size：</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" value="{$data.business_one.company_size}">
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">How did you hear about us?：</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" value="{$data.business_one.about_us_question}">
            </div>
        </div>
    </div>
    <div class="title_css">Verify your business.(2/2)</div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">Business address：</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" value="{$data.business_two.business_address}">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">Apartment,suite,floor,etc.：</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" value="{$data.business_two.business_apartment}">
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">City：</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" value="{$data.business_two.business_city}">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">State：</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" value="{$data.business_two.business_state}">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">ZIP：</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" value="{$data.business_two.business_zip}">
            </div>
        </div>
    </div>
    {if $data.business_two.mailing_type neq 1}
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">Mailing address：</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" value="{$data.business_two.mailing_address}">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">Apartment,suite,floor,etc.：</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" value="{$data.business_two.mailing_apartment}">
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">City：</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" value="{$data.business_two.mailing_city}">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">State：</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" value="{$data.business_two.mailing_status}">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">ZIP：</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" value="{$data.business_two.mailing_zip}">
            </div>
        </div>
    </div>
    {/if}
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">Website address：</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" value="{$data.business_two.website_address}">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">Incorporation type：</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" value="{$data.business_two.incorporation_type}">
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">State Corporate Number：</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" value="{$data.business_two.corporate_number}">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">Federal Tax ID(EIN)：</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" value="{$data.business_two.federal_tax_id}">
            </div>
        </div>
    </div>
    <div class="title_css">Verify your owner.(1/1)</div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">First Name：</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" value="{$data.owner.owner_first_name}">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">Last Name：</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" value="{$data.owner.owner_last_name}">
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">Job Title：</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" value="{$data.owner.owner_job_title}">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">Mobile Phone Number：</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" value="{$data.owner.owner_phone}">
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">Date of Birth：</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" value="{$data.owner.owner_date}">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">Home address：</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" value="{$data.owner.owner_address}">
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">Apartment,suite,floor,etc.：</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" value="{$data.owner.owner_apartment}">
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">City：</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" value="{$data.owner.owner_city}">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">State：</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" value="{$data.owner.owner_status}">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">ZIP：</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" value="{$data.owner.owner_zip}">
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">Social Security Numer：</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" value="{$data.owner.owner_ssn}">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">Precentage of Business Owned：</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" value="{$data.owner.owner_pbo}">
            </div>
        </div>
    </div>
    {if $data.owner.owner_type neq 1}
    <div class="title_css">Business Control Person/Officer</div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">First Name：</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" value="{$data.owner.owner_first_name2}">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">Last Name：</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" value="{$data.owner.owner_last_name2}">
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">Job Title：</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" value="{$data.owner.owner_job_title2}">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">Mobile Phone Number：</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" value="{$data.owner.owner_phone2}">
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">Date of Birth：</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" value="{$data.owner.owner_date2}">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">Home address：</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" value="{$data.owner.owner_address2}">
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">Apartment,suite,floor,etc.：</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" value="{$data.owner.owner_apartment2}">
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">City：</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" value="{$data.owner.owner_city2}">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">State：</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" value="{$data.owner.owner_status2}">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">ZIP：</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" value="{$data.owner.owner_zip2}">
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">Social Security Numer：</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" value="{$data.owner.owner_ssn2}">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">Precentage of Business Owned：</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" value="{$data.owner.owner_pbo2}">
            </div>
        </div>
    </div>
    {/if}
    <div class="title_css">1.Business Documents</div>
    <div class="layui-form-item" style="padding-left: 100px;">
        <br/>
        {foreach $data.bus_img as $bus_v}
            {if substr($bus_v,-3) == 'png' || substr($bus_v,-3) == 'jpg'}
                <span class="photo-list" style="padding-left: 50px;cursor:pointer;"><img src="{$bus_v}" style="width: 150px;height: 200px;"></span><br />
            {elseif substr($bus_v,-3) == 'pdf'}
                <span style="font-size: 16px;cursor:pointer;" onclick="open_file('{:str_replace(\'http\',\'https\',$bus_v)}')">{:str_replace('http','https',$bus_v)}</span><br/><br/>
            {else}
                <span style="font-size: 16px;">{:str_replace('http','https',$bus_v)}</span><br/><br/>
            {/if}
        {/foreach}
    </div>
    <div class="title_css">2.Personal Documents</div>
    <div class="layui-form-item" style="padding-left: 100px;">
        <br/>
        {foreach $data.pre_img as $pre_v}
            {if substr($pre_v,-3) == 'png' || substr($pre_v,-3) == 'jpg'}
            <span class="photo-list" style="padding-left: 50px;cursor:pointer;"><img src="{$pre_v}" style="width: 150px;height: 200px;"></span><br />
            {elseif substr($pre_v,-3) == 'pdf'}
            <span style="font-size: 16px;cursor:pointer;" onclick="open_file('{:str_replace(\'http\',\'https\',$pre_v)}')">{:str_replace('http','https',$pre_v)}</span><br/><br/>
            {else}
            <span style="font-size: 16px;">{:str_replace('http','https',$pre_v)}</span><br/><br/>
            {/if}
        {/foreach}
    </div>
    <br/>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label" style="font-size: 20px;font-weight: bold">Information Submitted：</label>
            <div class="layui-input-inline">
                {if $data.check_status eq 0}
                    <input type="radio" name="check_status" value="1" title="Yes">
                    <input type="radio" name="check_status" value="2" title="No">
                {else}
                    {if $data.check_status eq 1}
                        <input type="text" class="layui-input" value="Yes" style="color: green;font-size: 20px;font-weight: bold" >
                    {else}
                        <input type="text" class="layui-input" value="No" style="color: red;font-size: 20px;font-weight: bold">
                    {/if}
                {/if}
            </div>
        </div>
    </div>
    <input type="hidden" name="check_id" id="check_id" value="{$data.id}">
    <div class="layui-form-item" style="padding-top: 50px;">
        <div class="layui-input-block">
            {if $data.check_status eq 0}
            <button type="button" class="layui-btn" lay-submit lay-filter="edit">confirm</button>
            <button type="button" class="layui-btn" lay-submit lay-filter="changeToken">changeToken</button>
            {/if}
            <a href="{:url('check')}" class="layui-btn layui-btn-primary">{:lang('back')}</a>
        </div>
    </div>
</form>

<script>
    layui.use(['form'], function () {
        var form = layui.form;
        form.render();
        form.on('submit(edit)', function(data){
            var check_status = $("input[type='radio']:checked").val();
            if(check_status == 1){
                JsGet("{:url('checkSent')}?check_id=" + $("#check_id").val(), function(e){
                    if(e.status == 1){
                        layer.open({
                            type: 1,
                            title: 'Send Info',
                            area: ['800px', '500px'], //宽高
                            content: e.datas,
                            btn:['Confirm','Close'],
                            yes:function (index,layero) {
                                var thedata = $('.operationForm').serialize();
                                JsPost('{:url("checkEdit")}', thedata,function (re) {
                                    if(re.code >0){
                                        layer.msg(re.msg , {icon:1,time:1500});
                                        layer.close(index);
                                        window.location.href = "{:url('check')}";
                                    }else{
                                        layer.msg(re.msg, {icon:2,time:1500});
                                    }
                                });
                            }
                        });
                    }else{
                        layer.msg(e.msg);
                    }
                });
            }else{
                JsPost("{:url('checkEdit')}", data.field, function(res){
                    if(res.code){
                        layer.msg(res.msg, {time:1000},function(){
                            window.location.href = "{:url('check')}";
                        });
                    }else{
                        layer.msg(res.msg);
                    }
                })
            }
        });

        form.on('submit(changeToken)', function(data){
            JsGet("{:url('changeToken')}?check_id="+$("#check_id").val(), function(e){
                if(e.status == 1){
                    layer.open({
                        type: 1,
                        title: 'Change BusinessToken',
                        area: ['550px', '300px'], //宽高
                        content: e.datas,
                        btn:['Confirm','Close'],
                        yes:function (index,layero) {
                            var thedata = $('.operationForm').serialize();
                            var business_token   = $("#business_token").val();
                            if (business_token == '' || !business_token) {
                                layer.msg("Please Input BusinessToken." , {icon:2,time:1500});
                                return false;
                            }
                            JsPost('{:url("changeToken")}', thedata,function (re) {
                                if(re.code >0){
                                    layer.msg(re.msg , {icon:1,time:1500});
                                    layer.close(index);
                                    window.location.href = "{:url('check')}";
                                }else{
                                    layer.msg(re.msg, {icon:2,time:1500});
                                }
                            });
                        }
                    });
                }else{
                    layer.msg(e.msg);
                }
            });
        });

        $('.photo-list img').on('click', function () {
            layer.photos({
                photos: '.photo-list',
                shadeClose: false,
                closeBtn: 2,
                anim: 0
            });
        })

    });
    function open_file(content){
        layui.layer.open({
            type:2,
            title: 'File',
            area:['1000px' ,'600px'],
            fixed: false,
            maxmin: true,
            content: content
        });
    }
</script>
